﻿@page "/PDNOUpdataPage"
@inject CKDServer cKDServer
@using System.ComponentModel
@using AntDesign.TableModels
@inject ModalService _modalService
@inject MessageService _message
<h3>盘点</h3>
<div>
    <Row>
        <Col Span="24">请选择盘点作业表</Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@DataList"
                AllowClear="true"
                ValueOnClear="@("")"
                @bind-Value="@selet"
                ValueName="@nameof(PDBlist.FBILLNO)"
                LabelName="@nameof(PDBlist.Remark)">
        </Select>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <br>
        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@Creat">查询</Button>
        <br>
        <br>
        </Col>
    </Row>

        <Row>
              <Col Span="24">
       <label>@Result</label>
             </Col>
        </Row>


</div>


@code {
    string Result { get; set; }
    ObservableCollection<PDBlist> DataList { get; set; } = new ObservableCollection<PDBlist>();
    string  selet;
    protected override async Task OnInitializedAsync()
    {
        Result = "";
        var lists = await cKDServer.GetPDBS();
        DataList.Clear();
        foreach (var item in lists)
        {
            DataList.Add(item);
        }
        base.OnInitialized();
    }
    private async Task init()
    {

        var lists = await cKDServer.GetPDBS();
        DataList.Clear();
        foreach (var item in lists)
        {
            DataList.Add(item);
        }
        this.StateHasChanged();
    }

    private async Task Creat()
    {
        _modalService.Confirm(new ConfirmOptions()
            {
                Title = $"提示-{selet}",
                Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
              OkText = "确认",
              OnOk = async (e) =>
              {
                var aa = await cKDServer.GetPDBNOUPdata(selet);
              if (aa == null || aa.Count()==0)
              {
                    _message.Info("该盘点表没有待录入的批号");
            }
                  Result = "";

              foreach (var item in aa)
            {
                      Result += $"批号：{item.Flot}\r\n";

          }
              this.StateHasChanged();
              },
              CancelText = "取消",
              Content = "是否提交？",
          });
     

    }

    private async Task Creat2()
    {
        _modalService.Confirm(new ConfirmOptions()
            {
                Title = $"提示-{selet}-",
                Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
            OkText = "确认",
            OnOk = async (e) =>
            {
                var aa = await cKDServer.submitPD(selet);
                _message.Info(aa);
            },
            CancelText = "取消",
            Content = "是否提交？",
        });
    }
}
